<template>
  <div>
    item中的num
    <button @click="addNum">item里面的num+</button>
    {{ $store.state.item.num }}
    {{ itemNum }}
    <hr />
    order中的num
    {{ $store.state.order.num }}
    {{ orderNum }}
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  methods: {
    addNum () {
      // this['item/add_num'](5)
      // this.add_num(10)
      this.add_num(10)
    },
    // ...mapMutations(['item/add_num', 'order/add_num'])
    ...mapMutations('item', ['add_num', 'reduce_num'])
  },
  computed: {
    ...mapState({
      itemNum: (state) => state.item.num,
      orderNum: (state) => state.order.num
    })
  }
}
</script>

<style lang="scss" scoped>
</style>
